<template>
  <div>

    <button @click="change">显示/隐藏</button>
    <transition name="fade" appear>
      <h1 v-show="showFlag">c测试动画效果</h1>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Test",
  data() {
    return {
      showFlag: true,
    }
  },
  methods: {
    change() {
      this.showFlag = !this.showFlag
    }
  }

}
</script>

<style scoped>
h1 {
  background-color: orange;
}
.fade-enter-active, .fade-leave-active {
  transition: opacity .5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}
</style>